package com.gk.guinyote;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;


public class Baraja {

	public class Carta {

		private int numero;
		private String palo;
		private int valor;
		public Carta(int _numero, String _palo, int _valor){
			numero=_numero;
			palo=_palo;
			valor=_valor;
		}
		public int getNumero() {
			return numero;
		}
		public void setNumero(int numero) {
			this.numero = numero;
		}
		public String getPalo() {
			return palo;
		}
		public void setPalo(String palo) {
			this.palo = palo;
		}
		public int getValor() {
			return valor;
		}
		public void setValor(int valor) {
			this.valor = valor;
		}
		public String toString(){
			return (numero + " de " + palo);
		}
	}
	private ArrayList<Carta> mibaraja = new ArrayList<Carta>();
	List<String> palos = Arrays.asList("oros", "bastos", "copas", "espadas");
	public Baraja(){
		iniBaraja();
	}
	public Carta randomCard(){
		Random randomGenerator = new Random();
		int randomInt = randomGenerator.nextInt(mibaraja.size());
		Carta seleccionada = mibaraja.get(randomInt);
		Carta extraida = new Carta(seleccionada.getNumero(),seleccionada.getPalo(),seleccionada.getValor());
		mibaraja.remove(randomInt);
		return extraida;
	}
	public int numCartasBaraja(){
		return mibaraja.size();
	}
	public void iniBaraja(){
		for (String palo: palos){
			mibaraja.add(new Carta(1,palo,11));
			mibaraja.add(new Carta(2,palo,0));
			mibaraja.add(new Carta(3,palo,10));
			for (int i = 4; i<8; i++){
				mibaraja.add(new Carta(i,palo,0));
			}
			mibaraja.add(new Carta(10,palo,3));
			mibaraja.add(new Carta(11,palo,2));
			mibaraja.add(new Carta(12,palo,4));

		}
	}
	public void resetBaraja(){
		mibaraja.clear();
		iniBaraja();
	}
}